<template>
  <el-dialog :title="title" :visible="visible" @close="close">
    <table-pagination
      ref="table"
      class="table"
      :max-height="250"
      :columns="columns"
      :pagination-show="false"
      :data="data"
    />
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="close">关 闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import TablePagination from '@/components/common/TablePagination';
export default {
  name: 'TableDialog',
  components: {
    TablePagination
  },
  props: {
    visible: {
      type: Boolean,
      default: false
    },
    data: {
      type: Array,
      default: () => {
        return [];
      }
    },
    title: {
      type: String,
      default: ''
    },
    columns: {
      type: Array,
      default: () => {
        return [];
      }
    }
  },
  methods: {
    // 完成关闭弹窗
    close() {
      this.$emit('close');
      this.$nextTick(() => {
        this.$refs.table.handleTableScrollTop();
      });
    }
  }
};
</script>
